﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Heima.OA.Common.MeConfiguration
{
    /// <summary>
    /// 自定义配置节
    /// </summary>
    public class FirstConfig : ConfigurationSection
    {
        private static ConfigurationProperty _property = new ConfigurationProperty(string.Empty, typeof(KeyValueElementCollection), null, ConfigurationPropertyOptions.IsDefaultCollection);
        /// <summary>
        /// 配置列表
        /// </summary>
        [ConfigurationProperty("", Options = ConfigurationPropertyOptions.IsDefaultCollection)]
        private KeyValueElementCollection KeyValues
        {
            get { return (KeyValueElementCollection)base[_property]; }
            set { base[_property] = value; }
        }

        /// <summary>
        /// 最大大小
        /// </summary>
        public int MaxSize
        {
            get
            {
                int _value = 0;
                if (KeyValues["MaxSize"] != null) int.TryParse(KeyValues["MaxSize"].Value, out _value);
                return _value;
            }
            set
            {
                if (KeyValues["MaxSize"] == null) KeyValues["MaxSize"] = new KeyValueElement() { Key = "MaxSize", Value = value.ToString() };
                else KeyValues["MaxSize"].Value = value.ToString();
            }
        }
        public string IsDeclareTransferCheck
        {
            get
            {
                if (KeyValues["IsDeclareTransferCheck"] == null) return "true";
                return KeyValues["IsDeclareTransferCheck"].Value;
            }
            set
            {
                if (KeyValues["IsDeclareTransferCheck"] == null) KeyValues["IsDeclareTransferCheck"] = new KeyValueElement() { Key = "IsDeclareTransferCheck", Value = value };
                else KeyValues["IsDeclareTransferCheck"].Value = value;
            }
        }



    }
}
